package com.zookeeper

import org.I0Itec.zkclient.{ZkClient, ZkConnection}

object ZookeeperClient {
  def main(args: Array[String]): Unit = {
    val CONNECT_ADDR = "hadoop01:2181,hadoop02:2181,hadoop03:2181"
    val SESSION_TIMEOUT = 5000

    val zkClient = new ZkClient(new ZkConnection(CONNECT_ADDR), SESSION_TIMEOUT)

    val children = zkClient.getChildren("/sparkstreaming/vehicle_2")
    println(children)
    print(zkClient.exists("/sparkstreaming/c1"))
    val data = zkClient.readData[String]("/sparkstreaming/vehicle_2")
    print(data.toString)

//    zkClient.writeData("/super/c1", "新内容") //修改指定节点的值
//    println(zkClient.exists("/sparkstreaming/vehicle_090602"))
//    val cData = zkClient.readData("/sparkstreaming/vehicle_090602")
//    println(cData.toString)
//    println(zkClient.exists("/super/c1"))
//    zkClient.delete("/sparkstreaming/vehicle_0906_02")
//    println(zkClient.exists("/sparkstreaming/vehicle_0906_02"))
  }

}
